package com.qf.utils;

/**
 * 2019/12/10
 * qjh
 * springboot_oa_five
 * 面向对象面向君 不负代码不负卿
 */

import com.qf.entity.Annunciate;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 比较时间
 */
public class CompareTime {

    public static Map<Integer,Integer> compare(Date nowDate, Annunciate annunciate) {
        Map map = new HashMap();
        if(annunciate==null){
            return null;
        }else{
            int id =annunciate.getAnId();
            if (nowDate.getTime() < annunciate.getStartTime().getTime()) {
                //草稿
                map.put("anId", id);
                map.put("status",0);
            } else if (nowDate.getTime() > annunciate.getStartTime().getTime()&&nowDate.getTime() < annunciate.getEndTime().getTime()) {
                //发布
                map.put("anId", id);
                map.put("status",1);
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String date = formatter.format(annunciate.getStartTime());
                map.put("publishTime", date);
            } else {
                //已过期
                map.put("anId", id);
                map.put("status",-1);
            }
            return map;
        }
    }
}
